package com.yan.handler;

import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.Objects;

@Component
public class HandlerContext {
    private Map<String, AbstractHandler> map;

    public HandlerContext() {
        super();
    }

    public void setMap(Map<String, AbstractHandler> map) {
        this.map = map;
    }

    public AbstractHandler getInstance(String code) {
        Objects.requireNonNull(code);
        return map.get(code);
    }
}
